package com.anti.jdbc.core.executor.meta.resolver;


import com.anti.jdbc.core.executor.meta.Element;
import com.anti.jdbc.core.executor.meta.EntityElement;
import com.anti.jdbc.core.executor.meta.FieldElement;
import com.anti.jdbc.core.executor.supporrt.Assert;

import java.lang.annotation.Annotation;

public class VersionResolver implements Resolver{
    @Override
    public void resolve(Element element, Annotation annotation) {
        FieldElement fieldElement = (FieldElement)element;
        EntityElement entityElement = fieldElement.getEntityElement();
        Assert.isNull(entityElement.getVersion()
                , "实体：" + fieldElement.getName() + "只能有一个Version");
        fieldElement.setVersion(Boolean.TRUE);
        entityElement.setVersion(fieldElement);
    }
}
